package com.hl.web.fore;

import com.hl.pojo.HomeCarousel;
import com.hl.service.HomeCarouselService;
import com.hl.util.ResultEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/homeCarousel")
public class HomeCarouselController {
    @Autowired
    private HomeCarouselService homeCarouselService;
    @GetMapping("/findAll")
    public ResultEntity findAll(){
        return ResultEntity.ok(homeCarouselService.findAll()) ;
    }
    @GetMapping("/findAll1")
    public ResultEntity findAll1(){
        return ResultEntity.ok(homeCarouselService.findAll1()) ;
    }
    @GetMapping("/findById")
    public ResultEntity findById(int id){
        return ResultEntity.ok(homeCarouselService.findById(id)) ;
    }
    @PostMapping("/add")
    public ResultEntity add(@RequestBody HomeCarousel homeCarousel){
        return ResultEntity.ok(homeCarouselService.add(homeCarousel))  ;

    }
    @GetMapping("/delete")
    public ResultEntity delete(int id) {
        homeCarouselService.delete(id);
        return ResultEntity.ok();
    }
    @PostMapping("/update")
    public ResultEntity update(@RequestBody HomeCarousel homeCarousel) {
       return ResultEntity.ok(homeCarouselService.update(homeCarousel));
    }
}
